home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / BUS / TMCM Software and Labs.sit / Software for TMCM 7_95 / Files for Lab 13 / TwoTasks < prev   
Text File  |  1995-07-07  |  718b  |  40 lines

  1.   It is possible to use multitasking in xTurtle to perform
  2.   any two or more tasks simultaneously.  In this example,
  3.   two turtles perform independent "random walks".
  4.  
  5.   When you run this program, you will need to use the 
  6.   "Kill Program" command in the "Run" menu to stop it.
  7. }
  8.  
  9. fork(2)  { Split into two turtles }
  10.  
  11. IF ForkNumber = 1 THEN
  12.  
  13.    { Task to be performed by turtle #1... }
  14.  
  15.    PenUp
  16.    MoveTo(3,0)
  17.    PenDown
  18.    LOOP
  19.       face(90 * randomInt(4))
  20.       forward(0.5)
  21.       EXIT IF 1=2
  22.    END LOOP
  23.  
  24. OR IF ForkNumber = 2 THEN
  25.  
  26.    { Task to be performed by turtle #2... }
  27.  
  28.    PenUp
  29.    MoveTo(-3,0)
  30.    PenDown
  31.    LOOP
  32.       face(120 * randomInt(3))
  33.       forward(0.5)
  34.       EXIT IF 1=2
  35.    END LOOP
  36.  
  37. END IF
  38.  
  39.